<?php include("../includes/header-member.php") ?>
<title>LazySwim</title>
<link rel="stylesheet" href="store.css" type="text/css" />
</head>
<body>
<div id="page">
    <div id="page-top">
        <div id="page-bottom">
          <div id="header">
                <div id="header-info">
                    <h1>LAZYSWIM</h1>
                    <div class="description">Simplistic Swim System</div>
                </div>
				<!-- Header Goes Here -->
                <?php printHeader(); ?>
				<!-- Header Ends Here -->
                <div id="header-date">Today is <?php echo date('l, F jS, Y'); ?></div>
                <div id="header-cats">
				<!-- Welcome Message Starts Here -->
                    <ul>
					<?php include("../../includes/welcomeBar.php"); ?>
					</ul>
				<!-- Welcome Message Ends Here -->	
                </div>
            </div>
            <div id="main">
                <div id="sidebar">                 
                    <?php
					// include the corresponding navigation pages
                    include("shopSidebar.php");
                    include("../../includes/navigation.php");
					?>     
                </div>                     

            <!-- main body -->
            
            <?php
                $name = $_GET['name'];
                echo "<h2>View Product - $name</h2><br><br>";
                
                //fetch the products items
                $sql = "SELECT * FROM products WHERE name = '$name'";
                $items = mysql_query($sql) or die(mysql_error()); 
                $numberItems = mysql_num_rows($items);
            ?>
            
            <form name="addToCartForm" action="cart.php" method="post" >
                <input type="hidden" name="action" value="add">
                <table cellpadding=2 cellpadding=2 width="65%">
                <tr>
                    <?php if( $numberItems > 1){ echo"<th>Size</th>"; } ?>
                    <th>Price</th><th>Quantity</th></tr>
                <?php
                $total = 0;
                
                $i = 0;
                while($row = mysql_fetch_assoc($items)) { 
                    // this is just to make the table pretty with alternating tr colours
                    if($i % 2) { 
                        $class = 'row1'; 
                    } 
                    else { 
                        $class = 'row2'; 
                    } 
                    $i++;
                    
                    ?>
                    <tr class="<?php echo $class; ?>"> 
                        <?php if( $numberItems > 1 ) { echo "<td align=\"center\"> $row[size] </td>"; } ?>
                        <td align="center">$<?php echo $row[price]; ?></td> 
                        <td align="center">
                            <select name="<?php echo $row[productID];?>">
                            <option></option>
                            <?php
                                for($j = 1; $j <= 10; $j++ ) {
                                    echo "<option value=\"$j\">$j</option>";
                                }
                            ?>
                            </select>
                        </td>
                    </tr> 
                    
                <?php    
                }
                ?>
                </table>
                
                <table width="65%"><tr><td align="right">
                    <input type="submit" name="submit" value="Add Items to Cart">
                </td></tr></table>       
            </form>
            <!-- end of main -->
            
            <div class="clear"></div>

            </div>
			<!-- Footer Goes Here -->
            <?php include("../../includes/footer.php"); ?>
			<!-- Footer Ends Here -->
        </div>
    </div>
</div>
</body>
</html>